package com.com.appletest;
public class Test {
    public static void main(String[] args) {
        //创建两个worker对象
        Worker w = new Worker();
        //创建两个apple对象
        Apple apple = new Apple(5,"青色");
        Apple apple1 = new Apple(3,"红色");

        //创建两个策略对象
        w.pickApple(new CompareAble() {}, apple, apple1);
        w.pickApple(new CompareAble() {
            @Override
            public void compare(Apple apple, Apple apple2) {
                System.out.println("挑红的");
                if (apple.getColor().equals("红色")) {
                    System.out.println(apple);
                } else {
                    System.out.println(apple2);
                }
            }
            }, apple, apple1);
        // 创建两种“挑选策略”对象
        // 调用方法，分别使用不同的策略
    }
}
